package com.rds.web.controller.pms;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.rds.common.annotation.Log;
import com.rds.common.enums.BusinessType;
import com.rds.system.domain.RdaToolbar;
import com.rds.system.service.IRdaToolbarService;
import com.rds.common.core.controller.BaseController;
import com.rds.common.core.domain.AjaxResult;
import com.rds.common.utils.poi.ExcelUtil;
import com.rds.common.core.page.TableDataInfo;

/**
 * Toolbar管理Controller
 *
 * @author rds
 * @date 2021-05-25
 */
@RestController
@RequestMapping("/pms/toolbar")
public class RdaToolbarController extends BaseController
{
    @Autowired
    private IRdaToolbarService rdaToolbarService;

    /**
     * 查询Toolbar管理列表
     */
    @PreAuthorize("@ss.hasPermi('pms:toolbar:list')")
    @GetMapping("/list")
    public TableDataInfo list(RdaToolbar rdaToolbar)
    {
        startPage();
        List<RdaToolbar> list = rdaToolbarService.selectRdaToolbarList(rdaToolbar);
        return getDataTable(list);
    }

    /**
     * 导出Toolbar管理列表
     */
    @PreAuthorize("@ss.hasPermi('pms:toolbar:export')")
    @Log(title = "Toolbar管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RdaToolbar rdaToolbar)
    {
        List<RdaToolbar> list = rdaToolbarService.selectRdaToolbarList(rdaToolbar);
        ExcelUtil<RdaToolbar> util = new ExcelUtil<RdaToolbar>(RdaToolbar.class);
        return util.exportExcel(list, "toolbar");
    }

    /**
     * 获取Toolbar管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('pms:toolbar:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(rdaToolbarService.selectRdaToolbarById(id));
    }

    /**
     * 新增Toolbar管理
     */
    @PreAuthorize("@ss.hasPermi('pms:toolbar:add')")
    @Log(title = "Toolbar管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RdaToolbar rdaToolbar)
    {
        return toAjax(rdaToolbarService.insertRdaToolbar(rdaToolbar));
    }

    /**
     * 修改Toolbar管理
     */
    @PreAuthorize("@ss.hasPermi('pms:toolbar:edit')")
    @Log(title = "Toolbar管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RdaToolbar rdaToolbar)
    {
        return toAjax(rdaToolbarService.updateRdaToolbar(rdaToolbar));
    }

    /**
     * 删除Toolbar管理
     */
    @PreAuthorize("@ss.hasPermi('pms:toolbar:remove')")
    @Log(title = "Toolbar管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rdaToolbarService.deleteRdaToolbarByIds(ids));
    }
}
